/**
 * 
 */
package matrices.pruebas;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;

import algoritmos.CV;
import algoritmos.Lloyd;

import problema.Utilidades;

import Jama.Matrix;

import matrices.centro.Clase;

/**
 * @author Jose Antonio Gonzalez,Ambrin Chaudhary
 *
 */
public class LloydMain {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		Lloyd l = new Lloyd();
		
		double datos[][] = {{1,1},{1,3},{1,5},{2,2},{2,3},{6,3},{6,4},{7,1},{7,3},{7,5}};
		double centro1[][] = {{1,4}};
		double centro2[][] = {{7,2}};
		
		Vector<Clase> vectorCentros = new Vector<Clase>();
		Vector<Matrix> vectorMuestras = new Vector<Matrix>();
		
		Clase c = new Clase(); 
		
		c.setCentro(new Matrix(centro1));
		vectorCentros.add(c);
		c = new Clase(); 
		c.setCentro(new Matrix(centro2));
		vectorCentros.add(c);
		
		
		for (int i = 0; i< datos.length; i++)
		{
			double xiAux[][] = {{}};
			xiAux[0] = datos[i];
			vectorMuestras.add(new Matrix(xiAux));
		}
		
		/*Vector<Double> vaux = new Vector<Double>();
		vaux.add(new Double(1));
		vaux.add(new Double(2));
		vaux.add(new Double(3));
		
		Matrix xa = Utilidades.toMatrix(vaux);
		vectorMuestras.add(xa); */
		
		File f = new File("C:\\hlocal\\pruebaLloyd.txt");
		BufferedReader entrada = new BufferedReader( new FileReader(f));
		l.cargarFichero(entrada);
		
		/*File f1 = new File("C:\\hlocal\\pepe.txt");
		BufferedReader entrada1 = new BufferedReader( new FileReader(f1));
		CV cuantizacion = new CV();
		cuantizacion.cargarFichACuantizar(entrada1);
		cuantizacion.cuantizar(20.0);*/
		
		//l.cargarClases(cuantizacion.getClases(),cuantizacion.getMuestras());
		Vector<Double> lista = new Vector<Double>(8);
		
		System.out.println(l.toStringCentros());
		System.out.println(l.toStringMatrices());
		
		
		lista.add ( new Double(0.1));
		lista.add (null);
		lista.add ( null);
		lista.add ( new Double(1));
		lista.add ( null);
		lista.add ( null);
		lista.add ( new Double(0.01));
		l.entrenar(lista);
		
		System.out.println(l.toStringCentros());
		System.out.println(l.toStringMatrices());
		
		Vector<Double> v = new Vector<Double>();
		v.add(new Double(0.1));
		v.add(new Double(0.2));
		v.add(new Double(0.3));
		Utilidades.toMatrix(v);
		
		Vector<Double> vaux = new Vector<Double>();
		vaux.add(new Double(1));
		vaux.add(new Double(2));
		//vaux.add(new Double(3));
		
		l.ciclo(vaux);
		
		System.out.println(l.toStringCentros());
		System.out.println(l.toStringMatrices());

		
		System.out.println(10/3);
		
		vaux = new Vector<Double>();
		vaux.add(new Double(10));
		vaux.add(new Double(4));
		//vaux.add(new Double(3));
		
		l.ciclo(vaux);
		
		System.out.println(l.toStringCentros());
		System.out.println(l.toStringMatrices());

	}

}
